import request from '../utils/http-utils.js'
const systemApi = {
	LinkOperate: '/system/back/link',
	BoardOperate: '/system/back/board',
	TimelineOperate: '/system/back/timeline'
}

/**
 * 获取友链列表
 * @param {Object} page
 */
export function getLinkListByPage () {
	return request({
		url: systemApi.LinkOperate,
		method: 'get'
	})
}

/**
 * 添加友情链接
 * @param {Object} data
 */
export function addLink (data) {
	return request({
		url: systemApi.LinkOperate,
		method: 'post',
		data: data
	})
}

/**
 * 更新友情链接
 * @param {Object} data
 */
export function updateLink (data) {
	return request({
		url: systemApi.LinkOperate,
		method: 'put',
		data: data
	})
}

/**
 * 删除友情链接
 * @param {Object} id
 */
export function deleteLinkById (id) {
	return request({
		url: systemApi.LinkOperate + `/${id}`,
		method: 'delete'
	})
}

/**
 * 根据 ID 查询友链
 * @param {Object} id
 */
export function getLinkById (id) {
	return request({
		url: systemApi.LinkOperate + `/${id}`,
		method: 'get'
	})
}

// =========== 留言板相关 ==============

/**
 * 修改留言板 （后端无法在这里修改状态）
 * @param {Object} data
 */
export function updateBoard (data) {
	return request({
		url: systemApi.BoardOperate,
		method: 'put',
		data: data
	})
}

/**
 * 修改 status 状态 
 * @param {Object} status
 * @param {Object} id
 */
export function updateBoardStatus (status, id) {
	return request({
		url: systemApi.BoardOperate + `/${status}/${id}`,
		method: 'put'
	})
}


/**
 * 根据 ID 查询留言板
 * @param {Object} id
 */
export function getBoardById (id) {
	return request({
		url: systemApi.BoardOperate + `/${id}`,
		method: 'get'
	})
}

/**
 * 分页查询留言板
 * @param {Object} page
 */
export function getBoardByPage (page) {
	return request({
		url: systemApi.BoardOperate + '/page',
		method: 'post',
		data: page
	})
}

// ================= 时间轴相关 ======================

export function getTimeLineById (id) {
	return request({
		url: systemApi.TimelineOperate + `/${id}`,
		method: 'get'
	})
}

/**
 * 分页获取时间轴
 * @param {Object} page
 */
export function getTimeLineByPage (page) {
	return request({
		url: systemApi.TimelineOperate + '/page',
		method: 'post',
		data: page
	})
}

/**
 * 添加时间轴
 * @param {Object} data
 */
export function addTimeLine (data) {
	return request({
		url: systemApi.TimelineOperate,
		method: 'post',
		data: data
	})
}

/**
 * 修改时间轴
 * @param {Object} data
 */
export function updateTimeLine (data) {
	return request({
		url: systemApi.TimelineOperate,
		method: 'put',
		data: data
	})
}

/**
 * 修改时间轴的状态
 * @param {Object} id
 * @param {Object} enable
 */
export function enableTimeLine (id, enable) {
	return request({
		url: systemApi.TimelineOperate + `/${id}/${enable}`,
		method: 'put'
	})
}




